﻿#region Copyright (c) 2013-04, Olaf Kober <amarok.projects@gmail.com>
//================================================================================
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//================================================================================
#endregion

using System;


namespace Amarok.Agents
{
	/// <summary>
	/// This type represents the base class for agent implementations. Derived types must implement an agent-specific
	/// constructor that accepts agent environment and agent options. The agent instance is fully operational directly
	/// after construction and can receive and send messages.
	/// 
	/// Inside the agent various overloaded methods can be used to post and publish messages. Posting messages will
	/// send them to the agent instance itself. This can be used to implement workflows or state machines. Publishing 
	/// messages will send them to the outside world, meaning to subscribed agents and/or to a connected message bus, 
	/// which further forwards the messages to connected agents.
	/// </summary>
	/// 
	/// <typeparam name="TEnvironment">
	/// The type of agent environment used by this agent.</typeparam>
	/// <typeparam name="TOptions">
	/// The type of agent options used by this agent.</typeparam>
	public abstract class Agent<TEnvironment, TOptions> : Agent
		where TEnvironment : AgentEnvironment
		where TOptions : AgentOptions
	{
		#region ## Protected Interface ##

		/// <summary>
		/// Gets a reference to the agent's environment. The agent environment is used to give agents access to 
		/// the services of the runtime environment. One agent environment instance is shared between multiple 
		/// agents to provide the same services to all agents.
		/// </summary>
		protected new TEnvironment Environment
		{
			get
			{
				return (TEnvironment)base.Environment;
			}
		}

		/// <summary>
		/// Gets a reference to the agent's options. Agent options can be used to provide agent instances with 
		/// individual configurations and settings.
		/// </summary>
		protected new TOptions Options
		{
			get
			{
				return (TOptions)base.Options;
			}
		}


		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		/// 
		/// <param name="environment">
		/// The agent environment for this agent.</param>
		/// <param name="options">
		/// The agent options for this agent.</param>
		/// 
		/// <exception cref="ArgumentNullException">
		/// A null reference was passed to a method that did not accept it as a valid argument.</exception>
		protected Agent(TEnvironment environment, TOptions options)
			: base(environment, options)
		{
		}

		#endregion

	}
}
